/*
 * @Date: 2022-03-29 12:39:11
 * @LastEditors: luoqi
 * @LastEditTime: 2022-04-11 21:10:43
 * @FilePath: /payment/pay/src/pages/Tenant/TenantInfo.jsx
 */
import React,{useEffect,useState} from 'react'
 import erweiImg from '../../assests/images/二维码.png'
 import axios from '../../util/axios'
 import ReactDOM from 'react-dom'
 import qs from 'qs'
import {
  Form,
  Input,
  Switch,
} from 'antd';

export default function AgencyTenantInfo() {
  //表单默认内容
 let [ProduceOneInfo,setProduceOneInfo]=useState()
   let [number,setNumber]=useState(0)
  useEffect(()=>{
      axios({
      url:'/shangHuXinXi',
      method:'get',
      params:{'name':JSON.parse(localStorage.getItem('user')).uName}  ,
      async:true 
    }).then(res=>{
      console.log(res);
      if(res.code===200){
        let {nickName,yongHuId,rechargeRate}=res.data
        
        axios({
          url: '/ziJinMingXi/selectShangHuYuE',
          method: 'get',
          params:{name:JSON.parse(localStorage.getItem('user')).uName},
        }).then(res1 => {
          console.log(res1);
          if (res1.code == 200) {
            //批量修改状态
            ReactDOM.unstable_batchedUpdates(() => {
              setNumber(res1.data)
              setProduceOneInfo({
                produceName:nickName,
                produceId:yongHuId,
                MD5:'lkdhuaoigjfg',
                remaining:rechargeRate,
              })
            })
            
          }
        })
      }
    })  
   
  },[])
 

  return (
    <div>
      <div>商户资料</div>
      {ProduceOneInfo?<Form
      labelCol={{ span: 4 }}
      wrapperCol={{ span: 6 }}
      layout="horizontal"
      style={{'margin':'20px 0' }}
      initialValues={{produceName:ProduceOneInfo.produceName,produceId:ProduceOneInfo.produceId,MD5:ProduceOneInfo.MD5,remaining:number}}
    >
      <Form.Item label="商户名称" name="produceName">
        <Input disabled/>
      </Form.Item>
      <Form.Item label="商户号" name="produceId">
        <Input  disabled/>
      </Form.Item>
      <Form.Item label="MD5 Secret" name="MD5">
      <Input.TextArea disabled/>
      </Form.Item>
      <Form.Item label="商户余额" name="remaining">
        <Input disabled/>
      </Form.Item>
      <Form.Item label="谷歌认证二维码">
      <div>
      <img src={erweiImg}/>
      </div>
      </Form.Item>
      
      <Form.Item label="自动审核" valuePropName="checked">
        <Switch disabled/>
      </Form.Item>
    </Form>:''}
      
   
    </div>
  )
}